package com.ant.nets;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.ant.nets.activities.Demo001;
import com.ant.nets.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {
    private ListView mListView;
    private List<String> sls;
    private List<Class> cls;


    @Override
    public int getLaout() {
        sls = new ArrayList<>();
        cls = new ArrayList<>();
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        mListView = (ListView) findViewById(R.id.ac_main_lv_001);

    }

    @Override
    public void initData() {
        sls.add("demo001");
        cls.add(Demo001.class);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, sls);
        mListView.setAdapter(adapter);
    }

    @Override
    public void initListener() {
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent itemIntent = new Intent(MainActivity.this, cls.get(i));
                MainActivity.this.startActivity(itemIntent);
            }
        });
    }
}
